Generic programming with combinators and objects
Annotation
The generic programming approach is popular in functional languages (for example, OCaml, Haskell). In essence, it is a compile-time generation of code that performs transformations of user-defined data types. The generated code can carry out various kinds of transformations of the values. Usually, transformations are represented as functions that implement algorithms of transformation. New transformations could be built from these transformation functions and user-defined ones. The representation based on functions has a downside: functions behave as final representations, and hence it is not possible to modify the behavior of the already built function. If the current set of transformations does not suit well, software developers are obliged to write a completely distinct transformation, even in the case when the new transformation is almost identical to the existing one. This work proposes to build transformations that are extensible after construction. The object-oriented programming paradigm will be followed, transformations will be represented not as functions but as objects. Instead of calling a transformation function, one of the object’s methods will be called. The transformation itself will be split into methods. The extensibility is supported by adding new methods and overriding existing ones. In this paper, the authors propose an approach to represent transformations as objects in the OCaml functional programming language. Every alternative in data type definition has a corresponding object method. This design allows the construction of many distinct transformations. The cases where too many methods are not desirable are also discussed. The method is applicable to represent extensible transformations for polymorphic variant data types in OCaml when other methods fail to do it. The method is not bound to any particular domain. It allows the creation of extensible transformations in OCaml. It could be ported to other functional languages supporting object-oriented programming.
Keywords
Постоянный URL
Articles in current issue
- Features of images of water, ice, snow, objects and a human formed by a hybrid television camera in the near-infrared range
- Analyzing periodical textured silicon solar cells by the TCAD modeling
- Scintillation gamma radiation sensors based on solid-state photomultipliers in wireless industrial internet networks
- Improving the quality of network management of technological processes
- Geometric approach to the solution of the Dubins car problem in the formation of program trajectories
- Drift of two-dimensional vacancy islands on the Si(100) surface under electromigration conditions
- A study of the photocatalytic properties of chitosan-TiO2 composites for pyrene decomposition
- Kinetics of transformation of the atomic step bunches shape under electromigration conditions on the Si(001) surface
- Abnormal diffusion profile of adatoms on extremely wide terraces of the Si(111) surface
- An experimental methodology for assessing the probability and danger of network attacks in automated systems
- A meta-feature selection method based on the Auto-sklearn framework
- Automatic construction of the dialog tree based on unmarked text corpora in Russian
- Machine learning of the Bayesian belief network as a tool for evaluating the process frequency on social network data
- Software restructuring models for object oriented programming languages using the fuzzy based clustering algorithm
- The concept of managing the network structure of intelligent devices in the digital transformation of the energy industry
- Protecting facial images from recognition on social media: solution methods and their perspective
- Redundant models of testable distributed real-time computing systems
- A study of the influence of the base thickness on photoelectric parameters of silicon solar cells with the new TCAD algorithms
- A balanced algorithm of the hybrid large-particle method and its verification on some test problems
- The architecture of a system for full-text search by speech data based on a global search index
- Assessment of cerebral circulation through an intact skull using imaging photoplethysmography